import Vue from 'vue';
import iView from 'view-design';
import { router } from './router/index';
import { appRouter } from './router/router';
import store from './store';
import App from './app.vue';
import '@/locale';
import 'view-design/dist/styles/iview.css';
import VueI18n from 'vue-i18n';
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
import VueAMap from 'vue-amap';

import VueUeditorWrap from 'vue-ueditor-wrap';
Vue.component('vue-ueditor-wrap', VueUeditorWrap);
import VDistpicker from 'v-distpicker'

Vue.component('v-distpicker', VDistpicker)


import XUpload from "./views/common/upload";
Vue.use(XUpload);
import MoreUpload from "./views/common/moreUpload";
Vue.use(MoreUpload);

import vcolorpicker from 'vcolorpicker'
Vue.use(vcolorpicker)

Vue.use(VueAMap);
VueAMap.initAMapApiLoader({
    key: "98c1901b1ae19f37c29608d2d8582a44",
    plugin: ['AMap.Autocomplete', 'AMap.Loca', 'AMap.Scale', 'Geocoder', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
    v: '1.4.4'
});
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import VCharts from 'v-charts'

import VueCropper from 'vue-cropper'
Vue.use(VueCropper)
Vue.use(ElementUI);
Vue.use(VCharts)

Vue.use(VueI18n);
Vue.use(VueQuillEditor);
Vue.use(iView, {
    VueI18n: function (path, options) {
        let value = VueI18n.t(path, options)
        if (value !== null && value !== undefined) {
            return value
        }
        return ''
    }
});
new Vue({
    el: '#app',
    router: router,
    store: store,
    render: h => h(App),
    data: {
        currentPageName: ''
    },
    mounted() {
        this.currentPageName = this.$route.name;
        // 显示打开的页面的列表
        this.$store.commit('setOpenedList');
        this.$store.commit('initCachePage');
        // 权限菜单过滤相关
        this.$store.commit('updateMenuList');
    },
    created() {
        let tagsList = [];
        appRouter.map((item) => {
            if (item.children.length <= 1) {
                tagsList.push(item.children[0]);
            } else {
                tagsList.push(...item.children);
            }
        });
        this.$store.commit('setTagsList', tagsList);
    }
});
